//
//  BaseCollectionView.m
//  FloatClouds
//
//  Created by 黄威 on 16/9/2.
//  Copyright © 2016年 黄威. All rights reserved.
//

#import "BaseCollectionView.h"

@implementation BaseCollectionView

-(instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout{

    self = [super initWithFrame:frame collectionViewLayout:layout];
    
    if (self) {
        
        
        NSUserDefaults *nightIsOn = [NSUserDefaults standardUserDefaults];
        NSString *isOn = [nightIsOn objectForKey:@"night"];
                
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                         selector:@selector(ON)
                                                             name:@"NIGHTON"
                                                           object:nil];
                [[NSNotificationCenter defaultCenter] addObserver:self
                                                         selector:@selector(OFF)
                                                             name:@"NIGHTOFF"
                                                           object:nil];
        
                if ([isOn isEqualToString:@"0"]) {
                    
                    self.backgroundColor = [UIColor whiteColor];
                  
                }else if([isOn isEqualToString:@"1"]){
                    
                    self.backgroundColor = [UIColor colorWithRed:93/255.0 green:92/255.0 blue:101/255.0 alpha:1];
                    
                }
                
            }
            return self;
            
        }


- (void)ON{
       self.backgroundColor =  [UIColor colorWithRed:93/255.0 green:92/255.0 blue:101/255.0 alpha:1];
}
        
- (void)OFF{
   
            self.backgroundColor =[UIColor whiteColor];
    }


- (void)dealloc{
    
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NIGHTON" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NIGHTOFF"object:nil];
    
    
}
@end
